export const getPagingRange = ({ page = 1, pageLength = 10, totalRecords = 0 }) => {
  page = Number(page);
  pageLength = Number(pageLength);

  if (!page || page < 1) {
    page = 1;
  }
  if (!pageLength || pageLength < 1) {
    pageLength = 10;
  }
  if (((page - 1) * pageLength) >= totalRecords) {
    page = Math.ceil(totalRecords / pageLength);
  }

  const begin = (page - 1) * pageLength;
  const end = Math.min((page - 1) * pageLength + pageLength, totalRecords);

  return [begin, end];
};
